package com.winbomb.simulife.game.screens;

import com.winbomb.simulife.Ability;
import com.winbomb.simulife.Master;
import com.winbomb.simulife.framework.Game;
import com.winbomb.simulife.framework.Screen;
import com.winbomb.simulife.framework.Input.TouchEvent;
import com.winbomb.simulife.game.Assets;
import com.winbomb.simulife.game.GameScreen;
import com.winbomb.simulife.game.TouchArea;

public class MasterInfoScreen extends Screen {

	final TouchArea backArea = new TouchArea(10, 450, 75, 23);
	Master master;

	public MasterInfoScreen(Game game) {
		super(game);

		this.master = game.getWorld().getMaster();
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void present(float deltaTime) {

		g.drawPixmap(Assets.master_info_bg, 0, 0);

		g.drawText(master.getName(), 125, 25);
		g.drawText("男", 245, 25);

		StringBuffer sb = new StringBuffer();
		sb.append(master.getAgeYear());
		sb.append(" 岁 ");
		sb.append(master.getAgeMonth());
		sb.append(" 个月");
		g.drawText(sb.toString(), 125, 50);

		if (master.getJob() != null) {
			g.drawText(master.getJob().toString(), 245, 50);
		} else {
			g.drawText("无", 245, 50);
		}

		float h = master.getHeight() / 10000f;
		g.drawText(String.valueOf(h), 125, 75);
		g.drawText(String.valueOf(master.getWeight()), 245, 75);

		// draw master's ability
		g.drawText(String.valueOf(master.getAbility(Ability.KNOWLEDGE)), 60, 150);
		g.drawText(String.valueOf(master.getAbility(Ability.IQ)), 60, 175);
		g.drawText(String.valueOf(master.getAbility(Ability.SPORTS)), 60, 200);
		g.drawText(String.valueOf(master.getAbility(Ability.POLITICAL)), 60, 225);
		g.drawText(String.valueOf(master.getAbility(Ability.SINGING)), 60, 250);
		g.drawText(String.valueOf(master.getAbility(Ability.ACTING)), 60, 275);

		// draw master's family
		g.drawText(master.getFamily().toString(), 60, 300);

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(float deltaTime) {

		updateTouchEvents();

		for (TouchEvent event : touchEvents) {
			if (event.type != TouchEvent.TOUCH_UP) {
				continue;
			}

			if (backArea.isBound(event)) {

				game.setScreen(new GameScreen(game));
			}
		}

	}

}
